package com.fjrz.bbxwj.mode.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.fjrz.bbxwj.entity.CommonPhoneResponse
import com.fjrz.bbxwj.entity.CommonProtocolResponse
import com.fjrz.bbxwj.entity.CommonSplashResponse
import com.fjrz.bbxwj.entity.UserMeResponse
import com.fjrz.bbxwj.mode.api.commonData
import com.fjrz.bbxwj.mode.api.commonDevice
import com.fjrz.bbxwj.mode.api.commonSplash
import com.fjrz.bbxwj.mode.api.commonText
import com.module.lemlin.base.BaseViewModel
import com.module.lemlin.mode.ViewModelSubscribe
import com.module.lemlin.rxhttp.HttpServiceData
import com.module.lemlin.rxhttp.HttpServiceResponse
import io.reactivex.rxjava3.disposables.Disposable


class CommonViewModel(application: Application) : BaseViewModel(application) {


    val commonProtocolLiveData = MutableLiveData<HttpServiceResponse<CommonProtocolResponse>>()

    /**
     * 协议文本
     *
     * @param key about_us_text关于我们,user_agreement_text用户协议,privacy_policy_text隐私政策,common_problem_text常见问题
     * */
    fun commonText(key: String) {
        val disposable: Disposable =
            commonText(key, ViewModelSubscribe(commonProtocolLiveData))
        dispose.add(disposable)
    }


    val commonPhoneLiveData = MutableLiveData<HttpServiceResponse<CommonPhoneResponse>>()

    /**
     * 通用数据
     * */
    fun commonData() {
        val disposable: Disposable =
            commonData(ViewModelSubscribe(commonPhoneLiveData))
        dispose.add(disposable)
    }


    val commonSplashLiveData = MutableLiveData<HttpServiceResponse<CommonSplashResponse>>()

    /**
     * 通用数据
     * */
    fun commonSplash() {
        val disposable: Disposable =
            commonSplash(ViewModelSubscribe(commonSplashLiveData))
        dispose.add(disposable)
    }

    val commonDeviceLiveData = MutableLiveData<HttpServiceResponse<HttpServiceData>>()

    /**
     * 通用数据
     * */
    fun commonDevice( province: String, city: String) {
        val disposable: Disposable =
            commonDevice(province, city, ViewModelSubscribe(commonDeviceLiveData))
        dispose.add(disposable)
    }
}